package org.goat.caprabank.client;

import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.HasValue;

public class Validation {

	private Validation() {
	}

	public static boolean validateNotNull(HasText field, String fieldName) {
		boolean result = true;
		String text = field.getText();
		if (text == null || text.trim().isEmpty()) {
			new ErrorDialog().showMessage("Please enter a value into the " + fieldName + " field.");
			result = false;
		}
		return result;
	}


	public static boolean validateValue(HasValue<?> field, String fieldName) {
		boolean result = true;
		if (field.getValue() == null) {
			new ErrorDialog().showMessage("Please enter a valid value into the " + fieldName + " field.");
			result = false;
		}
		return result;
	}
}
